package com.oa.common.vo;

import com.oa.common.enums.FlowStatus;
import com.oa.common.enums.FlowType;
import com.oa.entities.flows.Flow;

import java.io.Serializable;

/**
 * 流程的返回类
 *
 */
public class FlowVo implements Serializable {

    private static final long serialVersionUID = -5186315106951362498L;

    /** 流程id **/
    private Long id;
    /** 名称 **/
    private String name;

    private String step;

    /** 步骤 **/
    private int num;

    /** 拟办人员 **/
    private String flowUser;

    /** 拟办的id **/
    private Long flowUserId;

    /** 发布人的id **/
    private Long issueId;

    /** 模版 **/
    private String appType;

    /** 模版的id **/
    private Long appTypeId;

    /** 流程的状态 **/
    private String flowStatus;

    /** 流程的类型 **/
    private String flowType;

    private String issue;

    private Boolean uable;

    private String desc;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getFlowUser() {
        return flowUser;
    }

    public void setFlowUser(String flowUser) {
        this.flowUser = flowUser;
    }

    public Long getFlowUserId() {
        return flowUserId;
    }

    public void setFlowUserId(Long flowUserId) {
        this.flowUserId = flowUserId;
    }

    public Long getIssueId() {
        return issueId;
    }

    public void setIssueId(Long issueId) {
        this.issueId = issueId;
    }

    public String getAppType() {
        return appType;
    }

    public void setAppType(String appType) {
        this.appType = appType;
    }

    public Long getAppTypeId() {
        return appTypeId;
    }

    public void setAppTypeId(Long appTypeId) {
        this.appTypeId = appTypeId;
    }

    public String getFlowStatus() {
        return flowStatus;
    }

    public void setFlowStatus(String flowStatus) {
        this.flowStatus = flowStatus;
    }

    public String getFlowType() {
        return flowType;
    }

    public void setFlowType(String flowType) {
        this.flowType = flowType;
    }

    @Override
    public String toString() {
        return "FlowVo{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", num=" + num +
                ", flowUser='" + flowUser + '\'' +
                ", flowUserId=" + flowUserId +
                ", issueId=" + issueId +
                ", appType='" + appType + '\'' +
                ", appTypeId=" + appTypeId +
                ", flowStatus='" + flowStatus + '\'' +
                ", flowType='" + flowType + '\'' +
                '}';
    }

    public FlowVo(Flow flow){
        this.name= flow.getName();
        this.appType= flow.getAppType().getTitle();
        this.flowStatus= FlowStatus.getMessage(flow.getFlowStatus());
        this.num= flow.getNum();
        this.flowType=FlowType.getMessage(flow.getFlowType());
        this.issue=flow.getIssue().getInfo()!=null?flow.getIssue().getInfo().getRealName():"管理员";
        this.step="第"+flow.getNum()+"步";
        this.id=flow.getId();
        StringBuilder builder= new StringBuilder();
        for (Flow flow1: flow.getFlows()){
            builder.append("-->"+flow1.getNum());
        }
        if (flow.getFlows().size()>0){
            this.uable= true;
        }else {
            this.uable= false;
        }
        this.desc= builder.toString();
    }

    public String getIssue() {
        return issue;
    }

    public void setIssue(String issue) {
        this.issue = issue;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getStep() {
        return step;
    }

    public void setStep(String step) {
        this.step = step;
    }

    public Boolean getUable() {
        return uable;
    }

    public void setUable(Boolean uable) {
        this.uable = uable;
    }
}
